home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / CPlusIncludes / SANE.h < prev    next >
Text File  |  1991-05-01  |  6KB  |  245 lines

  1. /************************************************************
  2.  
  3. Created: Wednesday, September 27, 1989 at 2:58 PM
  4.     SANE.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.     Copyright Apple Computer, Inc.    1985-1989
  9.     All rights reserved
  10.     
  11. Change log (relative to MPW 3.1 SANE.h)
  12.  
  13.     26 Oct 89 - Jon Okada
  14.         Removed initialization of IEEEDEFAULTENV for -mc68881 mode
  15.           (deferred to CLib881.o); declared IEEEDEFAULTENV extern.
  16.         Installed #include of Math.h.
  17.         Removed declarations of sqrt, log, exp, tan, cos, sin, and
  18.           atan (deferred to Math.h).
  19.         Changed declarations of functions power and inf to macro
  20.           definitions using pow and __inf.
  21.  
  22. ************************************************************/
  23.  
  24.  
  25. #ifndef __SANE__
  26. #define __SANE__
  27.  
  28. #ifndef __MATH__
  29. #include <Math.h>
  30. #endif
  31.  
  32. #ifdef mc68881
  33.  
  34. /* specific to the MC68881 SANE library */
  35.  
  36. #define INEXACT ((exception)(8))
  37. #define DIVBYZERO ((exception)(16))
  38. #define UNDERFLOW ((exception)(32))
  39. #define OVERFLOW ((exception)(64))
  40. #define INVALID ((exception)(128))
  41. #define CURINEX1 ((exception)(256))
  42. #define CURINEX2 ((exception)(512))
  43. #define CURDIVBYZERO ((exception)(1024))
  44. #define CURUNDERFLOW ((exception)(2048))
  45. #define CUROVERFLOW ((exception)(4096))
  46. #define CUROPERROR ((exception)(8192))
  47. #define CURSIGNAN ((exception)(16384))
  48. #define CURBSONUNOR ((exception)(32768))
  49.  
  50. #else
  51.  
  52. /* specific to the software SANE library */
  53.  
  54. #define INVALID ((exception)(1))
  55. #define UNDERFLOW ((exception)(2))
  56. #define OVERFLOW ((exception)(4))
  57. #define DIVBYZERO ((exception)(8))
  58. #define INEXACT ((exception)(16))
  59. #define IEEEDEFAULTENV ((environment)(0))    /*IEEE-default floating-point environment*/
  60.  
  61. #endif                                        /* mc68881 */
  62.  
  63. /* The common interface to the SANE library */
  64.  
  65. /* Decimal Representation Constants */
  66.  
  67. #define SIGDIGLEN 20                        /* significant decimal digits */
  68. #define DECSTROUTLEN 80                     /* max length for dec2str output */
  69.  
  70. /* Decimal Formatting Styles */
  71.  
  72. #define FLOATDECIMAL ((char)(0))
  73. #define FIXEDDECIMAL ((char)(1))
  74.  
  75. /* Ordering Relations */
  76.  
  77. #define GREATERTHAN ((relop)(0))
  78. #define LESSTHAN ((relop)(1))
  79. #define EQUALTO ((relop)(2))
  80. #define UNORDERED ((relop)(3))
  81.  
  82. /* Inquiry Classes */
  83.  
  84. #define SNAN ((numclass)(0))
  85. #define QNAN ((numclass)(1))
  86. #define INFINITE ((numclass)(2))
  87. #define ZERONUM ((numclass)(3))
  88. #define NORMALNUM ((numclass)(4))
  89. #define DENORMALNUM ((numclass)(5))
  90.  
  91. /* Rounding Directions */
  92.  
  93. #define TONEAREST ((rounddir)(0))
  94. #define UPWARD ((rounddir)(1))
  95. #define DOWNWARD ((rounddir)(2))
  96. #define TOWARDZERO ((rounddir)(3))
  97.  
  98. /* Rounding Precisions */
  99.  
  100. #define EXTPRECISION ((roundpre)(0))
  101. #define DBLPRECISION ((roundpre)(1))
  102. #define FLOATPRECISION ((roundpre)(2))
  103.  
  104. #ifdef mc68881
  105.  
  106. typedef long exception;
  107.  
  108.  
  109. struct extended80 {
  110.     short w[5];
  111. };
  112.  
  113. typedef struct extended80 extended80;
  114. struct environment {
  115.     long FPCR;
  116.     long FPSR;
  117. };
  118.  
  119. typedef struct environment environment;
  120.  
  121. extern environment IEEEDEFAULTENV;
  122.  
  123. struct trapvector {
  124.     void (*unordered)();
  125.     void (*inexact)();
  126.     void (*divbyzero)();
  127.     void (*underflow)();
  128.     void (*operror)();
  129.     void (*overflow)();
  130.     void (*signan)();
  131. };
  132.  
  133. typedef struct trapvector trapvector;
  134. #else
  135.  
  136. typedef short exception;
  137. typedef short environment;
  138. typedef struct {short w[6];} extended96;
  139.  
  140. struct mischaltinfo {
  141.     unsigned short haltexceptions;
  142.     unsigned short pendingCCR;
  143.     long pendingD0;
  144. };
  145.  
  146. typedef struct mischaltinfo mischaltinfo;
  147. typedef pascal void (*haltvector)(mischaltinfo *misc, void *src2, void *src, void *dst, short opcode);
  148. #endif
  149.  
  150. typedef short relop;                        /* relational operator */
  151. typedef short numclass;                     /* inquiry class */
  152. typedef short rounddir;                     /* rounding direction */
  153. typedef short roundpre;                     /* rounding precision */
  154.  
  155. struct decimal {
  156.     char sgn;                                /*sign 0 for +, 1 for -*/
  157.     char unused;
  158.     short exp;                                /*decimal exponent*/
  159.     struct{
  160.         unsigned char length;
  161.         unsigned char text[SIGDIGLEN];        /*significant digits */
  162.         unsigned char unused;
  163.         }sig;
  164. };
  165.  
  166. typedef struct decimal decimal;
  167. struct decform {
  168.     char style;                             /*FLOATDECIMAL or FIXEDDECIMAL*/
  169.     char unused;
  170.     short digits;
  171. };
  172.  
  173. typedef struct decform decform;
  174. #ifdef __cplusplus
  175. extern "C" {
  176. #endif
  177.  
  178. #ifdef mc68881
  179.  
  180. struct trapvector gettrapvector(void);
  181. void settrapvector(const trapvector& v);
  182. void x96tox80(const extended& x,extended80& x80);
  183. void x80tox96(const extended80& x80,extended& x);
  184.  
  185. #else
  186.  
  187. haltvector gethaltvector(void); 
  188. void sethaltvector(haltvector v);
  189. void x96tox80(const extended96& x96,extended& x);
  190. void x80tox96(const extended& x,extended96& x96);
  191.  
  192. #endif
  193.  
  194. void num2dec(const decform& f,extended x,decimal& d);
  195. extended dec2num(const decimal& d); 
  196. void dec2str(const decform& f,const decimal& d,char *s);
  197. void str2dec(const char *s,short& ix,decimal& d,short& vp); 
  198. extended remainder(extended x,extended y,short& quo);
  199. extended rint(extended x);
  200. extended scalb(short n,extended x); 
  201. extended logb(extended x);
  202. extended copysign(extended x,extended y);
  203. extended nextfloat(extended x,extended y);
  204. extended nextdouble(extended x,extended y); 
  205. extended nextextended(extended x,extended y);
  206. extended log2(extended x);
  207. extended log1(extended x);
  208. extended exp2(extended x);
  209. extended exp1(extended x);
  210.  
  211. #define power(x,y) pow(x,y)
  212.  
  213. extended ipower(extended x,short i);
  214. extended compound(extended r,extended n);
  215. extended annuity(extended r,extended n);
  216. extended randomx(extended& x);
  217. numclass classfloat(extended x);
  218. numclass classdouble(extended x);
  219. numclass classcomp(extended x); 
  220. numclass classextended(extended x); 
  221. long signnum(extended x);
  222. void setexception(exception e,long s);
  223. long testexception(exception e);
  224. void sethalt(exception e,long s);
  225. long testhalt(exception e); 
  226. void setround(rounddir r);
  227. rounddir getround(void);
  228. void setprecision(roundpre p);
  229. roundpre getprecision(void);
  230. void setenvironment(environment e); 
  231. void getenvironment(environment& e);
  232. void procentry(environment& e); 
  233. void procexit(environment e);
  234. relop relation(extended x,extended y);
  235. extended nan(unsigned char c);
  236.  
  237. #define inf() __inf()
  238.  
  239. extended pi(void);
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243.  
  244. #endif
  245.